import { createApp } from 'vue'
import App from './App.vue'
import 'virtual:svg-icons-register';
import 'uno.css'
import 'element-plus/dist/index.css'
import "./permission";
import router from "./router";
import pinia from "./stores";
import "./styles/index.scss";
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import ElementPlus from 'element-plus'
import 'element-plus/theme-chalk/dark/css-vars.css'
import directives from "@/directives/index";
import {initWebSocket} from '@/utils/websocketExample'
import { getUserInfo } from '@/utils/token-utils'
const userInfo = getUserInfo()
const apiEnv = localStorage.getItem('apiEnvironment')
const wsUrl = apiEnv === 'local' ? import.meta.env.VITE_WS_URL_LOCAL : import.meta.env.VITE_WS_URL_JAVA
initWebSocket({
    url: wsUrl+"/"+userInfo.userid,
    heartbeatInterval: 10000,
    heartbeatMessage: { command: 'heartbeat' ,data:{userId:userInfo.userid},eventType:"userId"},
    reconnectInterval: 5000,
    maxReconnectAttempts: 5,
})
const app = createApp(App)
app.use(ElementPlus, {
    locale: zhCn,
  })
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(router)
app.use(pinia)
app.use(directives)
app.mount('#app')


